package com.thread.lambal;

/**
 * @author xuejingjing
 * @className InterfaceATest
 * @description TODO
 * @date 2022/11/12/12 16:04
 */
public class InterfaceATest {
    public static void main(String[] args) {
        //interfaceA是接口的实现类对象
        InterfaceA interfaceA = new InterfaceA() {
            @Override
            public void eat() {
                System.out.println("eat");
            }
        };

        interfaceA.eat();
        System.out.println("-------------------------------");

        // interfaceA1 当前接口的实现类对象
        InterfaceA interfaceA1 = () -> { System.out.println("eat");};
        interfaceA1.eat();

        System.out.println("-------------------------------");
        // 调用方法
        //lambal表达式 表示当前接口的实现类对象（替换匿名内部类）
        methodA(() -> {System.out.println("eat....");});
    }

    private static void methodA(InterfaceA interfaceA) {
        interfaceA.eat();
    }
}
